﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Caifu.Datas;

namespace Caifu.Clients
{
	/// <summary>
	/// 预处净值操作类
	/// </summary>
	public static class NetValuePreClient
	{
		/// <summary>
		/// 添加预处净值。
		/// </summary>
		/// <param name="preFundNetValue"></param>
		public static void AddNetValuePre(NetValuePre preFundNetValue)
		{
			NetValuePreData.Instance
				.AddNetValuePre(preFundNetValue);
		}

		/// <summary>
		/// 修改预处净值。
		/// </summary>
		/// <param name="preFundNetValue"></param>
		public static void UpdateNetValuePre(NetValuePre preFundNetValue)
		{
			NetValuePreData.Instance
				.UpdateNetValuePre(preFundNetValue);
		}

		/// <summary>
		/// 删除预处净值。
		/// </summary>
		/// <param name="id"></param>
		public static void DeleteNetValuePre(Guid id)
		{
			NetValuePreData.Instance
				.DeleteNetValuePre(id);
		}

		/// <summary>
		/// 获取预处净值。
		/// </summary>
		/// <param name="id"></param>
		/// <returns></returns>
		public static NetValuePre GetNetValuePre(Guid id)
		{
			return NetValuePreData.Instance
				.GetNetValuePre(id);
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="fundCode"></param>
		/// <param name="reportDate"></param>
		/// <returns></returns>
		public static NetValuePre GetNetValuePre(string fundCode, DateTime reportDate)
		{
			return NetValuePreData.Instance
				.GetNetValuePre(fundCode, reportDate);
		}

		/// <summary>
		/// 获取预处净值。
		/// </summary>
		/// <param name="pageIndex"></param>
		/// <param name="pageSize"></param>
		/// <returns></returns>
		public static IList<NetValuePre> GetNetValuePres(Int32 pageIndex, Int32 pageSize)
		{
			return NetValuePreData.Instance
				.GetNetValuePres(pageIndex, pageSize);
		}

		/// <summary>
		/// 获取预处净值。
		/// </summary>
		/// <param name="pageIndex"></param>
		/// <param name="pageSize"></param>
		/// <returns></returns>
		public static IList<NetValuePre> GetNetValuePres(Guid fundId, Int32 pageIndex, Int32 pageSize)
		{
			return NetValuePreData.Instance
				.GetNetValuePres(fundId, pageIndex, pageSize);
		}

		/// <summary>
		/// 获取预处净值。
		/// </summary>
		/// <param name="fundCode"></param>
		/// <param name="pageIndex"></param>
		/// <param name="pageSize"></param>
		/// <returns></returns>
		public static IList<NetValuePre> GetNetValuePres(string fundCode, Int32 pageIndex, Int32 pageSize)
		{
			var fund = FundClient.GetFund(fundCode);
			if (fund == null) return new List<NetValuePre>();

			return NetValuePreData.Instance
				.GetNetValuePres(fund.Id, pageIndex, pageSize);
		}

		/// <summary>
		/// 获取预处净值。
		/// </summary>
		/// <param name="pageIndex"></param>
		/// <param name="pageSize"></param>
		/// <returns></returns>
		public static IList<NetValuePre> GetNetValuePres(DateTime reportDate, Int32 pageIndex, Int32 pageSize)
		{
			return NetValuePreData.Instance
				.GetNetValuePres(reportDate, pageIndex, pageSize);
		}

		/// <summary>
		/// 获取指定日期的预处净值。
		/// </summary>
		/// <param name="reportDate">报告日期</param>
		/// <returns></returns>
		public static IList<NetValuePre> GetNetValuePres(DateTime reportDate)
		{
			return GetNetValuePres(reportDate, 1, Int32.MaxValue);
		}
	}
}

